package com.lq.memo.controller;

import com.lq.memo.entity.MyResponse;
import com.lq.memo.exception.MyException;
import com.lq.memo.service.CalendarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @ClassName CalendarController
 * @Description
 * @Author LQ
 * @Date 2021/12/14 23:02
 * @Version 1.0
 */
@RestController
@RequestMapping("/calendar")
public class CalendarController {

    @Autowired
    CalendarService calendarService;

    @RequestMapping("/getLunarCalendar")
    public MyResponse getLunarCalendar(@RequestBody Map<String, Object> map) {
        MyResponse myResponse = new MyResponse().success();
        try {
            Map<Integer, Map<String,Object>> result = calendarService.getLunarCalendar(map);
            myResponse.data(result);
        } catch (MyException e) {
            myResponse.fail().message(e.toString());
            e.printStackTrace();
        }
        return myResponse;
    }
}
